package com.pengxun.manager.controller.system;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.pengxun.manager.model.system.RoleMenu;
import com.pengxun.manager.service.system.RoleMenuService;
import com.szeastroc.common.jdbc.page.Page;
import com.szeastroc.common.result.Result;
import com.szeastroc.common.result.ResultUtils;

@RestController
@RequestMapping("/roleMenu")
public class  RoleMenuController{

   @Resource
   private RoleMenuService roleMenuService;
   
   @RequestMapping("/insert")
   public Result insert(@RequestBody RoleMenu roleMenu){
       try{
          roleMenuService.insert(roleMenu);
       } catch (Exception e) {
			return ResultUtils.renderError(e.getMessage());
	   }
	   return ResultUtils.render();
   };
   
   @RequestMapping("/update")
   public Result update(@RequestBody RoleMenu roleMenu){
        try{
          roleMenuService.update(roleMenu);
       } catch (Exception e) {
			return ResultUtils.renderError(e.getMessage());
	   }
	   return ResultUtils.render();
   };
   
   @RequestMapping("/delete")
   public Result delete(Integer id){
       try{
          roleMenuService.delete(id);
       } catch (Exception e) {
			return ResultUtils.renderError(e.getMessage());
	   }
	   return ResultUtils.render();
   };
   
   @RequestMapping("/findByPage")
   public Result findByPage(Page page) {
		page = roleMenuService.findByPage(page);
		return ResultUtils.render(page);
	};
}
